package ewgenius.xube.engine.entities.primitives;

import static org.lwjgl.opengl.GL11.GL_LINES;
import static org.lwjgl.opengl.GL11.GL_POINTS;
import static org.lwjgl.opengl.GL11.glBegin;
import static org.lwjgl.opengl.GL11.glColor3f;
import static org.lwjgl.opengl.GL11.glEnd;
import static org.lwjgl.opengl.GL11.glVertex3d;

import org.lwjgl.util.vector.Vector3f;

import ewgenius.xube.engine.graphics.*;
import static ewgenius.xube.engine.physics.PhysicsEngine.*;

import ewgenius.xube.engine.entities.Entity;

public class Cube extends Entity {

	private float side = 0.001f * meter;
	
	public Cube(Vector3f pos) {
		super("cube", 0);
		position = new Vector3f(pos);

	}
	
	@Override
	public void render(Render render) {
		
		render.beginModelRender(position, rotation);

		glBegin(GL_POINTS);
		glVertex3d(position.x, position.y, position.z);
		glEnd();

		glBegin(GL_LINES);
		glColor3f(1, 1, 1);
		glVertex3d(position.x + side / 2, position.y + side / 2, position.z
				+ side / 2);
		glVertex3d(position.x + side / 2, position.y + side / 2, position.z
				- side / 2);
		glVertex3d(position.x + side / 2, position.y - side / 2, position.z
				+ side / 2);
		glVertex3d(position.x + side / 2, position.y - side / 2, position.z
				- side / 2);

		glVertex3d(position.x - side / 2, position.y + side / 2, position.z
				+ side / 2);
		glVertex3d(position.x - side / 2, position.y + side / 2, position.z
				- side / 2);
		glVertex3d(position.x - side / 2, position.y - side / 2, position.z
				+ side / 2);
		glVertex3d(position.x - side / 2, position.y - side / 2, position.z
				- side / 2);

		glVertex3d(position.x + side / 2, position.y + side / 2, position.z
				+ side / 2);
		glVertex3d(position.x - side / 2, position.y + side / 2, position.z
				+ side / 2);
		glVertex3d(position.x + side / 2, position.y - side / 2, position.z
				+ side / 2);
		glVertex3d(position.x - side / 2, position.y - side / 2, position.z
				+ side / 2);
		glVertex3d(position.x + side / 2, position.y + side / 2, position.z
				- side / 2);
		glVertex3d(position.x - side / 2, position.y + side / 2, position.z
				- side / 2);
		glVertex3d(position.x + side / 2, position.y - side / 2, position.z
				- side / 2);
		glVertex3d(position.x - side / 2, position.y - side / 2, position.z
				- side / 2);

		glVertex3d(position.x + side / 2, position.y + side / 2, position.z
				+ side / 2);
		glVertex3d(position.x + side / 2, position.y - side / 2, position.z
				+ side / 2);
		glVertex3d(position.x + side / 2, position.y + side / 2, position.z
				- side / 2);
		glVertex3d(position.x + side / 2, position.y - side / 2, position.z
				- side / 2);
		glVertex3d(position.x - side / 2, position.y + side / 2, position.z
				+ side / 2);
		glVertex3d(position.x - side / 2, position.y - side / 2, position.z
				+ side / 2);
		glVertex3d(position.x - side / 2, position.y + side / 2, position.z
				- side / 2);
		glVertex3d(position.x - side / 2, position.y - side / 2, position.z
				- side / 2);

		render.endModelRender();
	}

}
